/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package teamRoom111;


import battlecode.common.*;
import static battlecode.common.GameConstants.*;
import java.util.Random;

/**
 *
 * @author tulam4am
 */
public class ArchonPlayer implements Runnable {

    private final RobotController rc;

    public ArchonPlayer(RobotController rcInit) {
        rc = rcInit;
    }

    public void run()
    {
        Random r = new Random(1);

        while (true) {
            try {
                /*** beginning of main loop ***/
                while (rc.isMovementActive()) {
                    rc.yield();
                }

                if (rc.canMove(rc.getDirection())) {
                    try
                    {
                        RobotType[] rt = new RobotType[] {RobotType.WOUT, RobotType.AURA};

                        rc.spawn(rt[ r.nextInt(rt.length) ]);
                    }
                    catch (Exception e)
                    {
                        rc.moveForward();
                    }
                } else {
                    rc.setDirection(rc.getDirection().rotateRight());

                }

                rc.yield();

            /*** end of main loop ***/
            } catch (Exception e) {
                System.out.println("caught exception:");
                e.printStackTrace();
            }
        }
    }
}
